<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>重庆企业医院协会 志愿者后台</title>
    <include file="public@head_base"/>
    <style>
        .status-div {
            padding: 10px;
            width: 320px;
            margin: auto;
            text-align: center;
            margin-top: 120px;
        }

        .status-div img {
            width: 180px;
        }

        .status-div p {
            margin-top: 24px;
            font-size: 16px;
            color: #0055aa;
            text-align: center;
        }
    </style>
</head>
<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">
    <div class="layui-header">
        <div class="layui-logo">志愿者后台</div>
        <!-- 头部区域（可配合layui已有的水平导航） -->

        <ul class="layui-nav layui-layout-right">
            <li class="layui-nav-item">
                <a href="javascript:;">
                    <img src="{:cmf_get_image_url($volunteer.photo)}" class="layui-nav-img">
                    {$volunteer.name}
                </a>
            </li>
            <li class="layui-nav-item"><a href="{:cmf_url('volunteer/index/logout')}">退出</a></li>
        </ul>
    </div>

    <div class="layui-side layui-bg-black">
        <div class="layui-side-scroll">
            <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
            <ul class="layui-nav layui-nav-tree" lay-filter="test">
                <li class="layui-nav-item"><a href="{:cmf_url('volunteer/index/index')}">审核状态</a></li>
                <li class="layui-nav-item layui-this"><a href="{:cmf_url('volunteer/index/logs')}">活动记录</a></li>
            </ul>
        </div>
    </div>

    <div class="layui-body">
        <!-- 内容主体区域 -->
        <div style="padding: 15px;">
            <button type="button" class="layui-btn" id="add">添加</button>
            <table class="layui-table">
                <colgroup>
                    <col width="150">
                    <col width="200">
                    <col>
                </colgroup>
                <thead>
                <tr>
                    <th>活动时间</th>
                    <th>活动地点</th>
                    <th>主要内容</th>
                    <th>服务时间</th>
                    <th>备注</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                <foreach name="logs" item="item">
                    <tr>
                        <td>{$item.day}</td>
                        <td>{$item.address}</td>
                        <td>{$item.content}</td>
                        <td>{$item.time}</td>
                        <td>{$item.beizhu}</td>
                        <td><a class="layui-btn layui-btn-normal" href="javascript:edititem({$item['id']})">编辑</a><a
                                class="layui-btn layui-btn-danger ajax"
                                href="javascript:deleteitem({$item['id']})">删除</a></td>
                    </tr>
                </foreach>
                </tbody>
            </table>
        </div>
    </div>

    <div class="layui-footer">
        <!-- 底部固定区域 -->
        © kooki.cn - 技术支持 夼旗科技
    </div>
</div>
<include file="public@scripts"/>
<script>
    //JavaScript代码区域
    layui.use(['element', 'layer'], function () {
        var element = layui.element;
        var layer = layui.layer;

        $("#add").click(function () {
            layer.open({
                type: 2,
                title:'添加记录',
                content: "{:url('volunteer/index/add')}",
                area: ["600px",'480px']
            })
        })
    });

    function edititem(id) {
        layer.open({
            type: 2,
            title:'编辑记录',
            content: "{:url('volunteer/index/edit')}?id="+id,
            area: ["600px",'480px']
        })
    }
    function deleteitem(id) {
        console.log(id);
        layer.confirm('确定删除吗？', {
            btn: ['确定','取消'] //按钮
        }, function(index){
            $.get("{:url('volunteer/index/delete')}",{id:id},function (res) {
                if(res.code == 1){
                    window.location.reload();
                }else {
                    layer.msg(res.msg)
                }
            })
            layer.closeAll()

        }, function(index){
            layer.closeAll()
        });
    }
</script>
</body>
</html>
